﻿using System;
using System.Collections.Generic;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Media;
using System.IO;

namespace WindowsFormsApplication1
{
    public partial class EMail : Form
    {
        ArrayList imageList;
        Form1 theForm1;

        public EMail(Form1 aForm1, ArrayList aL)
        {
            InitializeComponent();
            imageList = aL;
            theForm1 = aForm1;

            listView1.TileSize = new System.Drawing.Size(100, 80);
            this.listView1.View = View.LargeIcon;
            this.listView1.LargeImageList = theForm1.imageList;

            int i = 0;

            ArrayList a = (ArrayList)imageList;

            foreach (object imageIndex in a)
            {
                listView1.Items.Add(theForm1.imageFileNameList[(int)imageIndex]);
                listView1.Items[i].ImageIndex = (int)imageIndex;
                i++;
            }

            autoComplete2.Text = theForm1.defaultFrom;

            i = theForm1.toAddess.Count - 1;
            String[] ss = new String[theForm1.toAddess.Count];

            foreach (string s in theForm1.toAddess)
            {
                ss[i] = s;

                i--;
            }

            autoComplete1.Values = ss;







            i = theForm1.fromAddress.Count - 1;
            ss = new String[theForm1.fromAddress.Count];

            foreach (string s in theForm1.fromAddress)
            {
                ss[i] = s;

                i--;
            }

            autoComplete2.Values = ss;
        }

        private void label1_Click(object sender, EventArgs e)
        {

        }

        private void textBox1_TextChanged(object sender, EventArgs e)
        {

        }

        private void button2_Click(object sender, EventArgs e)
        {


            Close();
        }

        private void button1_Click(object sender, EventArgs e)
        {
         //   autoComplete1.Text.

            if (autoComplete1.Text.Contains("@"))
            {
                theForm1.defaultFrom = autoComplete2.Text;
                theForm1.toAddess.Add(autoComplete1.Text);
                theForm1.fromAddress.Add(autoComplete2.Text);

                Close();
            }
            else
            {
                string soundClipLocation = Path.GetDirectoryName(Application.ExecutablePath).Replace("\\bin\\Debug", "\\Sounds\\ding.wav");
                SoundPlayer sp = new SoundPlayer(soundClipLocation);
                sp.Play();

                (new Form2()).ShowDialog();
            }
        }

        private void listView1_SelectedIndexChanged(object sender, EventArgs e)
        {
            listView1.SelectedItems.Clear();
        }
    }
}
